package me.xiaoyan.ehr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import me.xiaoyan.ehr.mapper.JobMapper;
import me.xiaoyan.ehr.po.Job;
import org.springframework.util.StringUtils;

import java.util.Map;

public class BaseService<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {
    public IPage<T> selectByPage(Map<String,String> params, QueryWrapper<T> queryWrapper){
        int page = 1,size = 10;
        if(StringUtils.hasLength(params.get("page_no"))){
            page = Integer.parseInt(params.get("page_no"));
        }
        if(StringUtils.hasLength(params.get("page_size"))){
            size = Integer.parseInt(params.get("page_size"));
        }
        Page<T> page1 = new Page<>(page,size);
        return this.getBaseMapper().selectPage(page1,queryWrapper);
    }
}
